package top.gohigh.springboot.service.impl;

import org.springframework.stereotype.Service;
import top.gohigh.springboot.dao.RoleDao;
import top.gohigh.springboot.model.Role;
import top.gohigh.springboot.service.RoleService;

import javax.annotation.Resource;

@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    RoleDao roleDao;
    @Override
    public Role getById(Long id) {
        return roleDao.findById(id).get();
    }

    @Override
    public Role add(String name) {
        Role role=new Role();
        role.setName(name);
        roleDao.save(role);
        return role;
    }

    @Override
    public Role update(Role role) {
        roleDao.save(role);
        return role;
    }
}
